********************************************************************
**** Keels, Joo, Wiegand Peace Duration Paper Replication Codes ****
****  	 Models were run on a Windows system PC, STATA V.17     **** 		
********************************************************************

* Note: All figures were produced using R (See R codes for figures)

* install packages 
ssc install cem, all //for CEM models
ssc install outreg2 // for creating tables in Word format from regression outputs

*******************************
*********  Main Paper *********
*******************************

***** Table 1 *****
use KJW_peaceduration_maindata.dta
stset peaceyears, failure(failure)

log using tab1

* Main 1 
stcox total_unad_pct total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, cluster(dyadid) robust nohr 
outreg2 using tab1.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

* Main 2  
stcox total_unad_durmaj_pct2 tot_durmajpct_time2 total_intangible2 lgdp democracy Polps polpower_time SsrDdr duration numreb war loot_sum, cluster(dyadid) robust nohr
outreg2 using tab1.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

* Main 3
stcox intangible_unad_pct2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum loot_time,  cluster(dyadid) robust nohr 
outreg2 using tab1.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

* Main 4 
stcox intang2_unad_durmaj_pct2 intangmaj_time22 total_intangible2 lgdp democracy Polps polpower_time SsrDdr duration numreb war war_time loot_sum, cluster(dyadid) robust nohr 
outreg2 using tab1.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close


************************************
*********  Online Appendix *********
************************************

***** Table A.3 *****
use KJW_peaceduration_maindata.dta
stset peaceyears, failure(failure)

log using tabA3

summarize total_unad_pct total_unad_durmaj_pct2 intangible_unad_pct2 intang2_unad_durmaj_pct2 intang2_unad_dum intang2_maj_unad_dum2 intangible_unad_pct intang_unad_durmaj_pct2 intangible_unad_pct3 intang3_unad_durmaj_pct2 total_unadpf_pct total_unadpf_durmaj_pct intang2_unadpf_pct intang2_unadpf_durmaj_pct pol_unadmaj_pct2 econ_unadmaj_pct2 nat_unadmaj_pct2 rel_unadmaj_pct2 eth_unadmaj_pct2 sd_unadmaj_pct2 state_unadmaj_pct2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum LaRef excluded past_agreement pko loot_dum

log close

***** Table A.4 *****
use KJW_peaceduration_maindata.dta
stset peaceyears, failure(failure)

log using tabA4

stcox pol_unadmaj_pct2 pol_unadmaj_pct2_time, cluster(dyadid) robust nohr
outreg2 using tabA4.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox econ_unadmaj_pct2, cluster(dyadid) robust nohr
outreg2 using tabA4.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+) 

stcox nat_unadmaj_pct2, cluster(dyadid) robust nohr 
outreg2 using tabA4.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox rel_unadmaj_pct2 rel_unadmaj_pct2_time, cluster(dyadid) robust nohr 
outreg2 using tabA4.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox eth_unadmaj_pct2 , cluster(dyadid) robust nohr 
outreg2 using tabA4.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox sd_unadmaj_pct2 , cluster(dyadid) robust nohr 
outreg2 using tabA4.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox state_unadmaj_pct2  , cluster(dyadid) robust nohr
outreg2 using tabA4.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close


***** Table A.5 ***** 
log using tabA5
use KJW_peaceduration_spoilerdata.dta

stset peaceyears, failure(failure2)

stcox total_unad_pct total_time total_intangible2 lgdp democracy Polps polpower_time SsrDdr duration numreb war war_time loot_sum, cluster(dyadid) robust nohr 
outreg2 using tabA5.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox total_unad_durmaj_pct2 tot_durmajpct_time2 total_intangible2 tot_intang2_time lgdp democracy dem_time Polps polpower_time SsrDdr duration numreb num_time war war_time loot_sum, cluster(dyadid) robust nohr
outreg2 using tabA5.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox intangible_unad_pct2 intangible2_time total_intangible2 lgdp democracy Polps polpower_time SsrDdr duration numreb war war_time loot_sum,  cluster(dyadid) robust nohr 
outreg2 using tabA5.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox intang2_unad_durmaj_pct2 intangmaj_time22 total_intangible2 tot_intang2_time lgdp democracy Polps polpower_time SsrDdr duration numreb num_time war war_time loot_sum, cluster(dyadid) robust nohr 
outreg2 using tabA5.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close


***** Table A.6 *****
use KJW_peaceduration_spoilerdata.dta
stset peaceyears, failure(failure3==1)

log using tabA6

stcrreg total_unad_pct total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, compete(failure3==2) cluster(dyadid) robust nohr 
outreg2 using tabA6.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcrreg total_unad_durmaj_pct2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, compete(failure3==2)  cluster(dyadid) robust nohr
outreg2 using tabA6.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcrreg intangible_unad_pct2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum,  compete(failure3==2) cluster(dyadid) robust nohr 
outreg2 using tabA6.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcrreg intang2_unad_durmaj_pct2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum,  compete(failure3==2) cluster(dyadid) robust nohr 
outreg2 using tabA6.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close


***** Table A.7 *****
use KJW_peaceduration_maindata.dta
stset peaceyears, failure(failure)

log using tabA7

stcox total_unad_pct total_intangible2 lgdp democracy Polps polpower_time SsrDdr duration numreb war loot_sum LaRef excluded excl_time past_agreement pko, cluster(dyadid) robust nohr  
outreg2 using tabA7.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox total_unad_durmaj_pct tot_durmajpct_time2 total_intangible2 lgdp democracy Polps polpower_time SsrDdr ddr_time duration numreb war loot_sum LaRef excluded excl_time past_agreement  pko, cluster(dyadid) robust nohr
outreg2 using tabA7.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox intangible_unad_pct2 total_intangible2 lgdp democracy dem_time Polps polpower_time SsrDdr ddr_time duration numreb num_time war loot_sum loot_time LaRef excluded past_agreement pko ,  cluster(dyadid) robust nohr 
outreg2 using tabA7.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox intang2_unad_durmaj_pct2 total_intangible2 lgdp democracy dem_time Polps polpower_time SsrDdr ddr_time duration numreb war loot_sum loot_time LaRef excluded past_agreement  pko, cluster(dyadid) robust nohr 
outreg2 using tabA7.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close


***** Table A.8 *****
use KJW_peaceduration_maindata.dta
stset peaceyears, failure(failure)

log using tabA8

stcox intangible_unad_pct total_intangible2 lgdp democracy Polps polpower_time SsrDdr duration numreb war loot_sum,  cluster(dyadid) robust nohr 
outreg2 using tabA8.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox intang_unad_durmaj_pct2 intangmajone_time22 total_intangible2 lgdp gdp_time democracy dem_time Polps polpower_time SsrDdr duration numreb war war_time loot_sum ,  cluster(dyadid) robust nohr 
outreg2 using tabA8.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox intangible_unad_pct3 total_intangible2 lgdp democracy Polps  SsrDdr duration numreb war loot_sum loot_time,  cluster(dyadid) robust nohr 
outreg2 using tabA8.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox  intang3_unad_durmaj_pct2 intangmaj_time32 total_intangible2 lgdp democracy Polps polpower_time SsrDdr duration numreb war loot_sum loot_time,  cluster(dyadid) robust nohr 
outreg2 using tabA8.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close 


***** Table A.9 *****
use KJW_peaceduration_maindata.dta
stset peaceyears, failure(failure)

log using tabA9

stcox total_unadpf_pct total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, cluster(dyadid) robust nohr 
outreg2 using tabA9.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox total_unadpf_durmaj_pct total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, cluster(dyadid) robust nohr
outreg2 using tabA9.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox intang2_unadpf_pct total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum loot_time,  cluster(dyadid) robust nohr 
outreg2 using tabA9.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

stcox intang2_unadpf_durmaj_pct total_intangible2 lgdp democracy Polps polpower_time SsrDdr duration numreb war loot_sum, cluster(dyadid) robust nohr 
outreg2 using tabA9.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close


***** Table A.10 *****
use KJW_peaceduration_maindata.dta
stset peaceyears, failure(failure)

log using tabA10

streg total_unad_pct total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum,  dist(weibull) cluster(dyadid) robust nohr
outreg2 using tabA10.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

streg total_unad_durmaj_pct2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum,  dist(weibull) cluster(dyadid) robust nohr
outreg2 using tabA10.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

streg intangible_unad_pct2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum,  dist(weibull) cluster(dyadid) robust nohr
outreg2 using tabA10.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

streg intang2_unad_durmaj_pct2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum,  dist(weibull) cluster(dyadid) robust nohr
outreg2 using tabA10.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close


***** Table A.11 *****
use KJW_peaceduration_intangCEM
stset peaceyears, failure(failure)

log using tabA11

cem numreb democracy past_agreement, treatment(intang2_unad_dum)
stset peaceyears [iw=cem_weights], fail(failure)
streg intang2_unad_dum total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, dist(w)  nohr
outreg2 using tabA11.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

cem numreb democracy past_agreement duration, treatment(intang2_unad_dum)
stset peaceyears [iw=cem_weights], fail(failure)
streg intang2_unad_dum total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, dist(w)  nohr
outreg2 using tabA11.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

cem numreb democracy past_agreement ethnic_all_dum, treatment(intang2_unad_dum)
stset peaceyears [iw=cem_weights], fail(failure)
streg intang2_unad_dum total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, dist(w)  nohr
outreg2 using tabA11.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

cem numreb democracy past_agreement loot_sum, treatment(intang2_unad_dum)
stset peaceyears [iw=cem_weights], fail(failure)
streg intang2_unad_dum total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, dist(w)  nohr
outreg2 using tabA11.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close 

clear 

***** Table A.12 *****
use KJW_peaceduration_endurintangCEM
stset peaceyears, failure(failure)

log using tabA12

cem numreb democracy past_agreement, treatment(intang2_maj_unad_dum2)
stset peaceyears [iw=cem_weights], fail(failure)
streg intang2_maj_unad_dum2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, dist(w)  nohr
outreg2 using tabA12.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

cem numreb democracy past_agreement duration, treatment(intang2_maj_unad_dum2)
stset peaceyears [iw=cem_weights], fail(failure)
streg intang2_maj_unad_dum2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, dist(w)  nohr
outreg2 using tabA12.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

cem numreb democracy past_agreement ethnic_all_dum, treatment(intang2_maj_unad_dum2)
stset peaceyears [iw=cem_weights], fail(failure)
streg intang2_maj_unad_dum2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, dist(w)  nohr
outreg2 using tabA12.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

cem numreb democracy past_agreement loot_sum, treatment(intang2_maj_unad_dum2)
stset peaceyears [iw=cem_weights], fail(failure)
streg intang2_maj_unad_dum2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum, dist(w)  nohr
outreg2 using tabA12.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close 

clear

***** Table A.13 *****
use KJW_peaceduration_intangCEM
stset peaceyears, failure(failure)

imb numreb democracy past_agreement, treatment(intang2_unad_dum)

cem numreb democracy past_agreement, treatment(intang2_unad_dum)

clear


***** Table A.14 *****
use KJW_peaceduration_endurintangCEM
stset peaceyears, failure(failure)

imb numreb democracy past_agreement, treatment(intang2_maj_unad_dum2)

cem numreb democracy past_agreement, treatment(intang2_maj_unad_dum2)

clear 

***** Table A.15 *****
use KJW_peaceduration_maindata.dta
stset peaceyears, failure(failure)

log using tabA15

stcox comprehensive total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum comprehensive, cluster(dyadid) robust nohr 
outreg2 using tabA14comp.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

* Main 1 
stcox total_unad_pct total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum comprehensive, cluster(dyadid) robust nohr 
outreg2 using tabA14.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

* Main 2  
stcox total_unad_durmaj_pct2 tot_durmajpct_time2 total_intangible2 lgdp democracy Polps polpower_time SsrDdr duration numreb war war_time loot_sum comprehensive, cluster(dyadid) robust nohr
outreg2 using tabA14.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

* Main 3
stcox intangible_unad_pct2 total_intangible2 lgdp democracy Polps SsrDdr duration numreb war loot_sum comprehensive,  cluster(dyadid) robust nohr 
outreg2 using tabA14.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

* Main 4 
stcox intang2_unad_durmaj_pct2 intangmaj_time22 total_intangible2 lgdp democracy dem_time Polps polpower_time SsrDdr duration numreb num_time war war_time loot_sum comprehensive comptime, cluster(dyadid) robust nohr 
outreg2 using tabA14.doc, append dec(3) pdec(3) alpha (0.001, 0.01, 0.05, 0.1) symbol(***,**,*,+)

log close


** End of file 
